package com.bwie.xujiahaonewstitle.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bwie.newstitlexujiahao.R;
import com.bwie.xujiahaonewstitle.MainActivity;
import com.bwie.xujiahaonewstitle.activity.PhoneLoginActivity;
import com.bwie.xujiahaonewstitle.activity.SetupActivity;
import com.makeramen.roundedimageview.RoundedImageView;
/**
 * 项目名称
 * 类描述：
 * 创建人：${徐家浩}
 * 创建时间：2017/2/17 19:33
 * 修改人：${徐家浩}
 * 修改备注：
 */
public class MeFragment extends Fragment implements View.OnClickListener{

    private View view;
    private ImageView mPhoneImageView;
    private ImageView mWeixinWeChat;
    private ImageView mQQImageView;
    private String scope = "all";
    private TextView mTextView;
    public static RelativeLayout mHideRelativeLayout;
    public static RoundedImageView mPwdRelativeLayout;
    public static TextView mNameTextView;
    public static RelativeLayout mShowTextView;
    private RelativeLayout mRelativeLayout;
    public static FrameLayout mFrameLayout;
    public static FrameLayout mFl2;
    private ImageView imageViewV4;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.mefragment, null);
        return view;
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initViews();
    }
    //获取资源ID
    private void initViews() {
        imageViewV4 = (ImageView) view.findViewById(R.id.f4_iv2);
        mRelativeLayout = (RelativeLayout) view.findViewById(R.id.f4_r3);
        mPhoneImageView = (ImageView) view.findViewById(R.id.f4_phone);//电话
        mWeixinWeChat = (ImageView) view.findViewById(R.id.f4_wechat);//微信
        mQQImageView = (ImageView) view.findViewById(R.id.f4_qq);//QQ登录按钮
        mFrameLayout = (FrameLayout) view.findViewById(R.id.fl1);
        mFl2 = (FrameLayout) view.findViewById(R.id.fl2);
        imageViewV4.setOnClickListener(this);
        mPhoneImageView.setOnClickListener(this);
        mWeixinWeChat.setOnClickListener(this);
        mQQImageView.setOnClickListener(this);
        mRelativeLayout.setOnClickListener(this);
        mTextView = (TextView) view.findViewById(R.id.ttttt);
        mHideRelativeLayout = (RelativeLayout) view.findViewById(R.id.f4_hide_r);
        mShowTextView = (RelativeLayout) view.findViewById(R.id.f4_show_r);
        mPwdRelativeLayout = (RoundedImageView) view.findViewById(R.id.iv_pwd_login);
        mNameTextView = (TextView) view.findViewById(R.id.f4_name_tv);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.f4_phone:
                Intent mIntent = new Intent(getActivity(),PhoneLoginActivity.class);
                startActivity(mIntent);
                break;
            case R.id.f4_wechat:

                break;
            case R.id.f4_qq:
//                Toast.makeText(getActivity(), "点了哈哈哈", Toast.LENGTH_SHORT).show();
                if (!MainActivity.mTencent.isSessionValid()) {
                    MainActivity.mTencent.login(getActivity(), scope, MainActivity.loginListener);
                }
                break;
            case R.id.f4_r3:
                Intent intent = new Intent(getActivity(), SetupActivity.class);
                startActivity(intent);
                break;
            case R.id.f4_iv2:

                break;
            default:
                break;
        }
    }
}